import { useEffect } from "react";
import useDvaData from './useDvaData';

function mapStateToProps(state) {
  return {
    loading: state.AdminUserService.getUserMenus_loading,
    getUserMenus: state.AdminUserService.getUserMenus
  };
}

export default (props) => {
  // 1、 使用dva数据
  const [dispatch, , , state] = useDvaData(props.app, mapStateToProps);

  useEffect(() => {
    if (!state.getUserMenus) dispatch("AdminUserService", "getUserMenus", {});
  }, [state.getUserMenus]);

  return state.getUserMenus;
};
